package com.ambitor.ipro.app.sche.builder;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ambitor.grass.sql.dao.SuperDao;
import com.ambitor.grass.util.data.DataMap;
import com.ambitor.grass.util.data.IData;
import com.ambitor.ipro.exceptions.ProException;
import com.ambitor.ipro.util.ResultCode;
import com.taobao.api.domain.Item;

public abstract class IModuleBuilder {

	private SuperDao superDao = null;

	private IData userSession = null;

	private IData userPro = null;

	private IData userStyle = null;

	private IData sstyle = null;

	private String installIid = null;

	private IData module;

	private int moduleId;

	protected final Logger logger = LoggerFactory.getLogger(this.getClass());

	public IModuleBuilder() {
	}

	public IData getSstyle() {
		return sstyle;
	}

	public void setSstyle(IData sstyle) {
		this.sstyle = sstyle;
	}

	public IData getModule() {
		return module;
	}

	public void setModule(IData module) {
		this.module = module;
	}

	public SuperDao getSuperDao() {
		return superDao;
	}

	public void setSuperDao(SuperDao superDao) {
		this.superDao = superDao;
	}

	public IData getUserSession() {
		return userSession;
	}

	public void setUserSession(IData userSession) {
		this.userSession = userSession;
	}

	public IData getUserPro() {
		return userPro;
	}

	public void setUserPro(IData userPro) {
		this.userPro = userPro;
	}

	public IData getUserStyle() {
		return userStyle;
	}

	public void setUserStyle(IData userStyle) {
		this.userStyle = userStyle;
	}

	public String getInstallIid() {
		return installIid;
	}

	public void setInstallIid(String installIid) {
		this.installIid = installIid;
	}

	public int getModuleId() {
		return moduleId;
	}

	public void setModuleId(int moduleId) {
		this.moduleId = moduleId;
	}

	@SuppressWarnings("unchecked")
	public void init() throws ProException {
		IData param = new DataMap();
		param.put("MODULE_ID", moduleId);
		try {
			module = this.getSuperDao().queryByPK("TD_P_MODULE", param);
		} catch (Exception e) {
			throw new ProException(ResultCode.DB_EXCEPTION, "查询TD_P_MODULE出错",
					e);
		}
	}

	public abstract String buildPromHTML(List<Item> allItemListToBePromoted)
			throws ProException;
}